import numpy as np
from array import array


#construct an array
a = np.array([(1,2,3)])
print(a)

b = np.zeros((2,3))
print(b)

c = np.ones((2,3), dtype=int, order='C')
print(c)

d = np.empty((2,3));
print(d)

print(np.arange(15))
print(np.arange(10,20,1))#等差数列

print(np.linspace(0, 2, 9, dtype=float))

x = np.ndarray(shape=(2,2),dtype=float,order='F')
print(x)
print(x.T)#转置
print(x.data)
print(x.dtype)
print(x.flat[0],x.flat[1],x.flat[2])#展开成1维


#运算
   #基本的一位算数运算
e = np.arange(4,12,3)
e = e - a
print(e)
e = e*e
print(e)
e = e *2
print(e)
e = e**3
print(e)
print(10*np.sin(e))
print(np.sin(1))

A = np.array([(1,2),
              (3,4)])
print(A)
B= np.array(([4,6],
             [8,9]))
print(B)
#元素乘法
print(A*B)
#转为矩阵乘法
print(np.dot(B,A))
print(np.dot(A,B))


